#include <iostream>
#include <algorithm>

using namespace std;

typedef long long LL;

const int N = 1010;
const LL P = 1e9 + 7;

int a[N];
int n;

int main()
{
	cin >> n;
	LL ret = 1;
	for(int i = 1; i <= n; i++) cin >> a[i];
	sort(a + 1, a + 1 + n);

	for(int i = 1; i <= n; i++)
	{
		ret = (ret * max(a[i] - i + 1, 0)) % P;
	}
	cout << ret << endl; 
	return 0;
}
